package com.sise.rsc.service;

import com.sise.rsc.entity.Courier;
import com.sise.rsc.entity.CourierStatus;
import com.sise.rsc.repository.CourierRepository;
import com.sise.rsc.repository.CourierStatusRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class CourierService {
    @Resource
    private CourierRepository courierRepository;
    @Resource
    private CourierStatusRepository courierStatusRepository;

    //查询所有快递员信息
    public List<Courier> findAllCourier(){
        return courierRepository.findAllCourier();
    }



    public void changStateToWorking(Courier courier){

        CourierStatus courierStatus = new CourierStatus();
        courierStatus.setTime(new Date());
        courierStatus.setCourier(courier);
        courierStatus.setStatus("正常");
        courierStatusRepository.save(courierStatus);
    }

    public List<Courier> findCouriersByWorkingAreaAddressNameLike(String address){
        return courierRepository.findCouriersByWorkingAreaAddressNameLike(address);
    }

    public List<CourierStatus> findCourierStatusesByStatusAndCourierId(String state,int cId){
        return courierStatusRepository.findCourierStatusesByStatusAndCourierId(state,cId);
    }

}
